//
//  ConfirmOrderViewController.m
//  MeterMart
//
//  Created by ENERGY on 2018/9/21.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "HotelOrderDetailViewController.h"
#import "PayWayViewController.h"
#import "WeChatLoginViewController.h"
@interface HotelOrderDetailViewController ()
@property (nonatomic, strong)UITableView * tableView;
@property (nonatomic, strong)UIView * headerView;
@property (nonatomic, strong)UIView * upAlertView;//顶部提示背景
@property (nonatomic, strong)UIView * middleWhiteView;//中部白色背景
@property (nonatomic, strong)UIView * bottomWhiteView;//中部白色背景
@property (nonatomic, strong)UIImageView * produceImg;//商品图片
@property (nonatomic, strong)UILabel * produceTitleLab;//商品名
@property (nonatomic, strong)UILabel * priceLab;//金额
@property (nonatomic, strong)UILabel * numLab;//数量
@property (nonatomic, strong)UILabel * listNumLab;//订单编号
@property (nonatomic, strong)NSString * listID;//订单ID
@property (nonatomic, strong)NSString * addressID;//地址ID
@property (nonatomic, strong)UILabel * dateContentLabl;//订单时间
@property (nonatomic, strong)UILabel * remarkContentLab;//备注信息
@property (nonatomic, strong)UIButton * submitBtn;//立即付款
@property (nonatomic, strong)NSString * totalMoney;//总金额
@property (nonatomic, strong)NSDictionary * modelData;
@property (nonatomic, strong)NSString * numString;//数量
@property (nonatomic, strong)NSString * produceName;//商品名称
@property (nonatomic, strong)NSString * produceDescribe;//商品描述
@property (nonatomic, strong)UILabel * inHotelLab;//入住日期
@property (nonatomic, strong)UIView * middleLineView;//横线
@property (nonatomic, strong)UILabel * outHotelLab;//离店日期
@property (nonatomic, strong)UILabel * liveTitleLab;//入住时间
@property (nonatomic, strong)UIView * liveBottomLine;//下面横线
@property (nonatomic, strong)UILabel * dateTitleLab;//下单时间标题
@property (nonatomic, strong)UIView * dateBottomLine;//下单下横线
@property (nonatomic, strong)UILabel * remarkTitleLab;//备注标题
@property (nonatomic, strong)UIView * bottomBar;//底部付款条
@property (nonatomic, strong)UIView * expendBottomLine;//消费码下面横线
@property (nonatomic, strong)UILabel * expendCodeTitleLab;//消费码标题
@property (nonatomic, strong)UILabel * expendCodeContentLab;//消费码内容
@property (nonatomic, strong)NSString * phoneString;
@property (nonatomic, strong)NSString * tokenString;
- (void)ifLogin;
@end

@implementation HotelOrderDetailViewController(networkin)
- (void)getOrderDetailsData{
    NSDictionary * dic = @{
                           @"orderid":self.myOrderListStr,
                           @"phone":self.phoneString,
                           @"token":self.tokenString,                           };
    [self showprogressHUD];
    [[AFAppDotNetAPIClient sharedClient] POST:@"orderiosApi/orderDetails" parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self hiddenProgressHUD];
        if ([responseObject[@"sign"] isEqualToString:@"1"]) {
            self.modelData = responseObject[@"list"][@"details"][0];
        }else if ([[NSString stringWithFormat:@"%@", responseObject[@"sign"]] isEqualToString:@"400"]) {
            [self ifLogin];
        }else{
            ShowMessage(responseObject[@"msg"]);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self hiddenProgressHUD];
        [self showError:error];
    }];
}
@end
@implementation HotelOrderDetailViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setStatusBarBackgroundColor:[UIColor clearColor]];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    if ([[UserModel sharedInstanced].token isEqualToString:@""] || [UserModel sharedInstanced].token == nil || [[UserModel sharedInstanced].token length] == 0 || [[UserModel sharedInstanced].mobile isEqualToString:@""] || [UserModel sharedInstanced].mobile == nil || [[UserModel sharedInstanced].mobile length] == 0) {
        self.tokenString = @"";
        self.phoneString = @"";
    }else{
        self.tokenString = [UserModel sharedInstanced].token;
        self.phoneString = [UserModel sharedInstanced].mobile;
    }
    [self getOrderDetailsData];//网络接口
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = getColor(mainColor);
    self.navigationItem.title = @"订单详情";
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    [self.view addSubview:self.tableView];
    [self setUpBottomTabBarView];
}

#pragma mark - init
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVI_HEIGHT - BOTTOM_HEIGHT - 49/WIDTH_6_SCALE) style:UITableViewStylePlain];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = getColor(mainColor);
        _tableView.tableHeaderView = self.headerView;
    }return _tableView;
}
- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVI_HEIGHT - BOTTOM_HEIGHT - 49/WIDTH_6_SCALE)];
        _headerView.backgroundColor = getColor(mainColor);
        [self setUpMiddleWhiteView];
        [self setUpBottomWhiteView];
    }return _headerView;
}
- (void)setUpMiddleWhiteView{
    //中部白色背景
    self.middleWhiteView = [[UIView alloc] init];
    self.middleWhiteView.backgroundColor = [UIColor whiteColor];
    [_headerView addSubview:self.middleWhiteView];
    //商品图片
    self.produceImg = [[UIImageView alloc] init];
    self.produceImg.image = [UIImage imageNamed:@"YimiPlaceHolder"];
    [self.middleWhiteView addSubview:self.produceImg];
    //商品名
    self.produceTitleLab = [[UILabel alloc] init];
    [self label:self.produceTitleLab withFont:DEF_FontSize_14 withText:@"商品名称" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.middleWhiteView];
    self.produceTitleLab.numberOfLines = 0;
    self.produceTitleLab.lineBreakMode = 0;
    //商品价格
    self.priceLab = [[UILabel alloc] init];
    [self label:self.priceLab withFont:DEF_FontSize_15 withText:[NSString stringWithFormat:@"￥%@", @"4200"] withTextColor:getColor(mainRedColor) withTextAlignment:NSTextAlignmentLeft withView:self.middleWhiteView];
    //数量
    self.numLab = [[UILabel alloc] init];
    [self label:self.numLab withFont:DEF_FontSize_15 withText:[NSString stringWithFormat:@"X   %@", @"-"] withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentRight withView:self.middleWhiteView];
    //masonry
    __weak typeof (self)weakSelf = self;
    [self.middleWhiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.headerView);
        make.top.equalTo(weakSelf.headerView.mas_top);
        make.height.mas_offset(150/WIDTH_6_SCALE);
    }];
    [self.produceImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.middleWhiteView.mas_left).mas_offset(25/WIDTH_6_SCALE);
        make.top.equalTo(weakSelf.middleWhiteView.mas_top).mas_offset(23/WIDTH_6_SCALE);
        make.width.height.mas_offset(111/WIDTH_6_SCALE);
    }];
    [self.produceTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.produceImg.mas_right).mas_offset(30/WIDTH_6_SCALE);
        make.top.equalTo(weakSelf.middleWhiteView.mas_top).mas_offset(26/WIDTH_6_SCALE);
        make.right.equalTo(weakSelf.middleWhiteView.mas_right).mas_offset(-16/WIDTH_6_SCALE);
        make.bottom.lessThanOrEqualTo(weakSelf.priceLab.mas_top).mas_offset(-10/WIDTH_6_SCALE);
    }];
    [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.produceTitleLab.mas_left);
        make.bottom.equalTo(weakSelf.middleWhiteView.mas_bottom).mas_offset(-32/WIDTH_6_SCALE);
    }];
    [self.numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.middleWhiteView.mas_right).mas_offset(-18/WIDTH_6_SCALE);
        make.top.bottom.equalTo(weakSelf.priceLab);
    }];
}
- (void)setUpBottomWhiteView{
    //底部白色背景
    self.bottomWhiteView = [[UIView alloc] init];
    self.bottomWhiteView.backgroundColor = [UIColor whiteColor];
    [_headerView addSubview:self.bottomWhiteView];
    //订单编号标题
    UILabel * listTitleLab = [[UILabel alloc] init];
    [self label:listTitleLab withFont:DEF_FontSize_14 withText:@"订单编号" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.bottomWhiteView];
    //订单编号内容
    self.listNumLab = [[UILabel alloc] init];
    [self label:self.listNumLab withFont:DEF_FontSize_12 withText:@"---" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentRight withView:self.bottomWhiteView];
    //订单下横线
    UIView * listBottomLine = [[UIView alloc] init];
    listBottomLine.backgroundColor = getColor(@"f7f7f7");
    [self.bottomWhiteView addSubview:listBottomLine];
    //下单时间标题
    UILabel * dateTitleLab = [[UILabel alloc] init];
    self.dateTitleLab = dateTitleLab;
    [self label:dateTitleLab withFont:DEF_FontSize_14 withText:@"下单时间" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.bottomWhiteView];
    //下单时间内容
    self.dateContentLabl = [[UILabel alloc] init];
    [self label:self.dateContentLabl withFont:DEF_FontSize_12 withText:@"---" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentRight withView:self.bottomWhiteView];
    //下单下横线
    UIView * dateBottomLine = [[UIView alloc] init];
    self.dateBottomLine = dateBottomLine;
    dateBottomLine.backgroundColor = getColor(@"f7f7f7");
    [self.bottomWhiteView addSubview:dateBottomLine];
    //消费码标题
    self.expendCodeTitleLab = [[UILabel alloc] init];
    [self label:self.expendCodeTitleLab withFont:DEF_FontSize_14 withText:@"消费码" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.bottomWhiteView];
    //消费码内容
    self.expendCodeContentLab = [[UILabel alloc] init];
    [self label:self.expendCodeContentLab withFont:DEF_FontSize_12 withText:@"---" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentRight withView:self.bottomWhiteView];
    //消费码下横线
    self.expendBottomLine = [[UIView alloc] init];
    self.expendBottomLine.backgroundColor = getColor(@"f7f7f7");
    [self.bottomWhiteView addSubview:self.expendBottomLine];
    //入住时间标题
    self.liveTitleLab = [[UILabel alloc] init];
    [self label:self.liveTitleLab withFont:DEF_FontSize_14 withText:@"入住时间" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.bottomWhiteView];
    //入住时间
    self.inHotelLab = [[UILabel alloc] init];
    [self label:self.inHotelLab withFont:DEF_FontSize_12 withText:@"入住" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentCenter withView:self.bottomWhiteView];
    //离店时间
    self.outHotelLab = [[UILabel alloc] init];
    [self label:self.outHotelLab withFont:DEF_FontSize_12 withText:@"离店" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentCenter withView:self.bottomWhiteView];
    //中间横线
    self.middleLineView = [[UIView alloc] init];
    self.middleLineView.backgroundColor = [UIColor grayColor];
    [self.bottomWhiteView addSubview:self.middleLineView];
    //入住标题底横线
    self.liveBottomLine = [[UIView alloc] init];
    self.liveBottomLine.backgroundColor = getColor(@"f7f7f7");
    [self.bottomWhiteView addSubview:self.liveBottomLine];
    //备注标题
    UILabel * remarkTitleLab = [[UILabel alloc] init];
    self.remarkTitleLab = remarkTitleLab;
    [self label:remarkTitleLab withFont:DEF_FontSize_14 withText:@"备注信息" withTextColor:[UIColor blackColor] withTextAlignment:NSTextAlignmentLeft withView:self.dateContentLabl];
    //备注内容
    self.remarkContentLab = [[UILabel alloc] init];
    self.remarkContentLab.lineBreakMode = 0;
    self.remarkContentLab.numberOfLines = 0;
    [self label:self.remarkContentLab withFont:DEF_FontSize_12 withText:@"" withTextColor:getColor(textGrayColor) withTextAlignment:NSTextAlignmentLeft withView:self.dateContentLabl];
    //masonry
    __weak typeof (self)weakSelf = self;
    [self.bottomWhiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.headerView);
        make.top.equalTo(weakSelf.middleWhiteView.mas_bottom).mas_offset(10/WIDTH_6_SCALE);
        make.bottom.equalTo(weakSelf.remarkContentLab.mas_bottom);
    }];
    [listTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.headerView.mas_left).mas_offset(20/WIDTH_6_SCALE);
        make.top.equalTo(weakSelf.bottomWhiteView.mas_top);
        make.height.mas_offset(57/WIDTH_6_SCALE);
    }];
    [self.listNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.headerView.mas_right).mas_offset(-20/WIDTH_6_SCALE);
        make.top.bottom.equalTo(listTitleLab);
    }];
    [listBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(listTitleLab.mas_left);
        make.right.equalTo(weakSelf.listNumLab.mas_right);
        make.height.mas_offset(1/WIDTH_6_SCALE);
        make.top.equalTo(listTitleLab.mas_bottom);
    }];
    [self.expendCodeTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.with.height.equalTo(listTitleLab);
        make.top.equalTo(listBottomLine.mas_bottom);
    }];
    [self.expendCodeContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.right.equalTo(weakSelf.listNumLab);
        make.top.equalTo(weakSelf.expendCodeTitleLab.mas_top);
    }];
    [self.expendBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.left.equalTo(listBottomLine);
        make.top.equalTo(weakSelf.expendCodeTitleLab.mas_bottom);
    }];
    [dateTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.with.height.equalTo(listTitleLab);
        make.top.equalTo(weakSelf.expendBottomLine.mas_bottom);
    }];
    [self.dateContentLabl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.right.equalTo(weakSelf.listNumLab);
        make.top.equalTo(dateTitleLab.mas_top);
    }];
    [dateBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.left.equalTo(listBottomLine);
        make.top.equalTo(dateTitleLab.mas_bottom);
    }];
    [self.liveTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.width.equalTo(dateTitleLab);
        make.top.equalTo(dateBottomLine.mas_bottom);
    }];
    [self.inHotelLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.middleLineView.mas_left).mas_offset(-10/WIDTH_6_SCALE);
        make.top.height.equalTo(weakSelf.liveTitleLab);
    }];
    [self.outHotelLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.dateContentLabl.mas_right);
        make.top.height.equalTo(weakSelf.liveTitleLab);
    }];
    [self.middleLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.inHotelLab.mas_centerY);
        make.right.equalTo(weakSelf.outHotelLab.mas_left).mas_offset(-10/WIDTH_6_SCALE);
        make.width.mas_offset(10/WIDTH_6_SCALE);
        make.height.mas_offset(2/WIDTH_6_SCALE);
    }];
    [self.liveBottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.liveTitleLab.mas_bottom);
        make.height.mas_offset(1/WIDTH_6_SCALE);
        make.width.mas_offset(SCREEN_WIDTH);
    }];
    [remarkTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.height.width.equalTo(dateTitleLab);
        make.top.equalTo(self.liveBottomLine.mas_bottom);
    }];
    [self.remarkContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.height.equalTo(weakSelf.dateContentLabl);
        make.top.equalTo(remarkTitleLab.mas_top);
    }];
}
- (void)setUpBottomTabBarView{
    UIView * bottomBar = [[UIView alloc] init];
    bottomBar.backgroundColor = [UIColor whiteColor];
    self.bottomBar = bottomBar;
    [self.view addSubview:bottomBar];
    //提交订单
    UIButton * submitBtn = [[UIButton alloc] init];
    submitBtn.titleLabel.font = DEF_FontSize_15;
    [submitBtn setTitle:@"立即付款" forState:UIControlStateNormal];
    [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [submitBtn addTarget:self action:@selector(submitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [bottomBar addSubview:submitBtn];
    submitBtn.userInteractionEnabled = NO;
    self.submitBtn = submitBtn;
    //masonry
    __weak typeof (self)weakSelf = self;
    [bottomBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.bottom.equalTo(weakSelf.view.mas_bottom).mas_offset(-BOTTOM_HEIGHT);
        make.height.mas_offset(49/WIDTH_6_SCALE);
    }];
    [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_offset(134/WIDTH_6_SCALE);
        make.right.equalTo(bottomBar.mas_right).mas_offset(-7/WIDTH_6_SCALE);
        make.top.equalTo(bottomBar.mas_top).mas_offset(7/WIDTH_6_SCALE);
        make.bottom.equalTo(bottomBar.mas_bottom).mas_offset(-7/WIDTH_6_SCALE);
    }];
}
- (void)setModelData:(NSDictionary *)modelData{
    _modelData = modelData;
    [self.produceImg sd_setImageWithURL:[NSURL URLWithString:modelData[@"goodsimg"]] placeholderImage:[UIImage imageNamed:@""]];
    self.produceTitleLab.text = [NSString stringWithFormat:@"%@  %@", modelData[@"goodsname"], modelData[@"desc"]];
    self.produceName = modelData[@"goodsname"];
    self.produceDescribe = modelData[@"desc"];
    self.priceLab.text = [NSString stringWithFormat:@"￥%@", modelData[@"goodsagencyprice"]];
    self.numLab.text = @"x  1";
    self.numString = modelData[@"goodssum"];
    self.listNumLab.text = modelData[@"ordernum"];
    self.dateContentLabl.text = [self ConvertStrToTime:modelData[@"createtime"]];
    self.remarkContentLab.text = modelData[@"remarks"];
    self.listNumLab.text = modelData[@"ordernum"];
    if ([modelData[@"paystatus"] isEqualToString:@"1"]) {
        //已付款
        [self.submitBtn setBackgroundColor:[UIColor grayColor]];
        self.submitBtn.userInteractionEnabled = NO;
        self.submitBtn.hidden = YES;
    }else if ([modelData[@"paystatus"] isEqualToString:@"0"]){
        //未付款
        [self.submitBtn setBackgroundColor:getColor(@"e92600")];
        self.submitBtn.userInteractionEnabled = YES;
        self.submitBtn.hidden = NO;
    }else if ([modelData[@"paystatus"] isEqualToString:@"2"]){
        //审核中
        [self.submitBtn setBackgroundColor:[UIColor grayColor]];
        self.submitBtn.userInteractionEnabled = NO;
        self.submitBtn.hidden = YES;
    }else if ([modelData[@"paystatus"] isEqualToString:@"3"]){
        //已退款
        [self.submitBtn setBackgroundColor:[UIColor grayColor]];
        self.submitBtn.userInteractionEnabled = NO;
        self.submitBtn.hidden = YES;
    }else if ([modelData[@"paystatus"] isEqualToString:@"4"]){
        //已拒绝
        [self.submitBtn setBackgroundColor:[UIColor grayColor]];
        self.submitBtn.userInteractionEnabled = NO;
        self.submitBtn.hidden = YES;
    }else if ([modelData[@"paystatus"] isEqualToString:@"5"]){
        //审核通过
        [self.submitBtn setBackgroundColor:[UIColor grayColor]];
        self.submitBtn.userInteractionEnabled = NO;
        self.submitBtn.hidden = YES;
    }
    if ([modelData[@"start"] isEqualToString:@"0"]) {
        self.inHotelLab.hidden = YES;
        self.middleLineView.hidden = YES;
        self.outHotelLab.hidden = YES;
        self.liveTitleLab.hidden = YES;
//        self.bottomWhiteView.hidden = YES;
        __weak typeof (self)weakSelf = self;
        [self.remarkTitleLab mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.height.width.equalTo(self.dateTitleLab);
            make.top.equalTo(self.dateBottomLine.mas_bottom);
        }];
        [self.remarkContentLab mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.right.height.equalTo(weakSelf.dateContentLabl);
            make.top.equalTo(weakSelf.remarkTitleLab.mas_top);
        }];
        [self.bottomWhiteView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(weakSelf.headerView);
            make.top.equalTo(weakSelf.middleWhiteView.mas_bottom).mas_offset(10/WIDTH_6_SCALE);
            make.bottom.equalTo(weakSelf.remarkContentLab.mas_bottom);
        }];
    }else{
        self.inHotelLab.hidden = NO;
        self.middleLineView.hidden = NO;
        self.outHotelLab.hidden = NO;
        self.liveTitleLab.hidden = NO;
//        self.bottomWhiteView.hidden = NO;
        self.inHotelLab.text = modelData[@"start"];
        self.outHotelLab.text = modelData[@"end"];
    }
    if ([modelData[@"accounting"] isEqualToString:@""] || [modelData[@"accounting"] length] == 0 || modelData[@"accounting"] == nil) {
        self.expendCodeContentLab.text = @"---";
    }else{
        self.expendCodeContentLab.text = modelData[@"accounting"];
    }
    self.listID = modelData[@"ordernum"];
    self.addressID = modelData[@"addressid"];
    self.totalMoney = modelData[@"totalmoney"];
}
#pragma mark - action
- (void)ifLogin{
    WeChatLoginViewController * vc = [[WeChatLoginViewController alloc] init];
    UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:vc];
    vc.backHomePageBlock = ^{
        [vc dismissViewControllerAnimated:YES completion:nil];
        [self.tabBarController setSelectedIndex:0];
        [self.navigationController popToRootViewControllerAnimated:YES];
    };
    [self presentViewController:navi animated:YES completion:nil];
}
- (void)arrowCoverBtnClick:(UIButton *)sender{
    NSLog(@"箭头");
}
- (void)submitBtnClick:(UIButton *)sender{
    PayWayViewController * vc = [[PayWayViewController alloc] init];
    vc.listID = self.listID;
    vc.addressID = self.addressID;
    vc.numString = self.numString;
    vc.produceDescribe = self.produceDescribe;
    vc.produceTitle = self.produceName;
    if (self.remarkContentLab.text == nil || [self.remarkContentLab.text isEqualToString:@""] || [self.remarkContentLab.text length] == 0) {
        vc.remarks = @"";
    }else{
        vc.remarks = self.remarkContentLab.text;
    }
    [self.navigationController pushViewController:vc animated:YES];
}

//时间戳变为格式时间
- (NSString *)ConvertStrToTime:(NSString *)timeStr{
    long long time=[timeStr longLongValue];
    //    如果服务器返回的是13位字符串，需要除以1000，否则显示不正确(13位其实代表的是毫秒，需要除以1000)
    //    long long time=[timeStr longLongValue] / 1000;
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString*timeString=[formatter stringFromDate:date];
    return timeString;
}
@end
